package com.goal98.team.services

import com.goal98.team.domain.Person
import com.goal98.grails.plugin.account.domain.Account

class PersonService {

    boolean transactional = true

    def openAccount(Person person) {
        if(person.account != null)
            throw new Exception("Person ${person.username} already has a account!")
        Account account = new Account(reference:person.username, balance:0)
        person.account = account
        account.save()
        person.save(flush:true)

    }
}
